package com.cuihanyu.newuniversityover.adapter;

import android.app.Activity;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.cuihanyu.newuniversityover.R;
import com.cuihanyu.newuniversityover.bean.HomeInfoBean;
import com.cuihanyu.newuniversityover.util.MyLogUtil;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by Administrator on 2017/9/11.
 */

public class HomeRecyclerviewAdapter extends BaseQuickAdapter<HomeInfoBean.TableBean, HomeRecyclerviewAdapter.ViewHolder> {
    private Activity activity;
    private RequestOptions options;

    @Override
    public int getItemViewType(int position) {
        return super.getItemViewType(position);
    }

    public HomeRecyclerviewAdapter(Activity activity, @Nullable List<HomeInfoBean.TableBean> data) {
        super(R.layout.home_gv_item, data);
        this.activity = activity;
    }

    @Override
    protected void convert(ViewHolder helper, final HomeInfoBean.TableBean item) {
        if (options == null) {
            options = new RequestOptions();
            options.error(R.drawable.banner1);
        }
        Glide.with(activity).load(item.getImageURL()).apply(options).into(helper.mImage);
        helper.mTitle.setText(item.getVideo_Name());
    }


    static class ViewHolder extends BaseViewHolder {
        @BindView(R.id.ImageView_item)
        ImageView mImage;
        @BindView(R.id.TextView_item)
        TextView mTitle;

        ViewHolder(View view) {
            super(view);
            ButterKnife.bind(this, view);
        }
    }
}
